<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href="${ctx}/styles/listTable.css" rel="stylesheet" type="text/css">
<%@ include file="/commons/tabs.jsp" %>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">
	function Project(){
		this.projectId = null;
		/*******设置当前期数ID*********/
		this.setProjectInfo = function(projectId){
			this.projectId = projectId;
		}
		//检查期数ID是否为空
		this.checkProjectId = function(){
			if(this.projectId == null || this.projectId == ""){
				ErrorAlert("${key.tipsBySelect}");
				return false;
			}
			return true;
		}
		this.editProject = function(){
			if(!this.checkProjectId()) return;

			openProjectEdit();
		}
		/*********删除期数*************/
		this.deleteProject = function () {
			//没有选择记录，提示选择条记录
			if(!this.checkProjectId()){
				return;
			}
			AskConfirm("${key.tipsByDeleteConfirm}","mainFrame","projectDelete");
		}
	}
	/**************公用方法********************/
	/****楼盘修改****/
	function openAreaEdit(){
		var url = "${ctx}/house_areaAction.do?method=initAreaBaseEdit&areaId=${areaId}";
		top.windowOpen(url,"areaBaseEdit","${key.area_edit}",530,700,true,"areaBaseEditFrameid");
	}

	/****期数增加*****/
	function openProjectAdd(){
		var url = "${ctx}/house_projectAction.do?method=initProjectAdd";
		projectWindowOpen(url,"${key.porject_add}");
	}
	/****期数修改******/
	function openProjectEdit(){
		var url = "${ctx}/house_projectAction.do?method=initPorjectEdit&porjectId=" + project.projectId;
		projectWindowOpen(url,"${key.project_edit}");
		project.projectId = null;
		flushList();
	}
	function projectWindowOpen(url,title){
		top.windowOpen(url,"projectAdd",title,570,800,true,"projectAddFrameId");
	}
	/****期数删除*****/
	function projectDelete(){
		var url = "${ctx}/house_projectAction.do?method=deleteProjectById";
		var str = "projectId=" + project.projectId;
		new Ajax.Request(url,
	                    {method: 'post', parameters: str, onComplete: function(result){
	                    												ajaxSubmitException(result.responseText);
	                    												project.projectId = null;
	                    												flushList();}
	                    										}
	                    );
	}

	///当楼盘不分期开发时，要求隐藏期数tab
	function hiddenProjectTab(){
		hideTab('projectInfo');
		document.getElementById("projectOption").style.visibility = "hidden";
	}
	//当楼盘分期开发时，要求显示期数tab
	function showProjectTab(){
		showTab('projectInfo');
		document.getElementById("projectOption").style.visibility = "visible";
	}
	function clickAreaInfoTab(){
		onClickTab('areaBaseInfo');
	}
	function flushList(){
		window.frames("areaInfo").document.location.reload();
	}
	var project = null;
	function init(){
		project = new Project();
		<c:if test="${areavo.hasMoreProject eq 0}">
			hiddenProjectTab();
		</c:if>
		<c:if test="${areavo.hasMoreProject eq 1}">
			showProjectTab();
		</c:if>
	}
</script>
</head>
<body onload="init();">

<div id="projectOption" style="display:none">
 <table border="0" cellpadding="0" cellspacing="0" id="ico1" >
     <tr>
       <td class="toolbarico"><a href="#"  onClick="openProjectAdd();" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新增期数"/></a> </td>
       <td class="toolbarico"><a href="#"  onClick="project.editProject();" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改期数"/></a></td>
       <td class="toolbarico"><a href="#" onClick="project.deleteProject();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></td>
     </tr>
 </table>
</div>
<!-- 楼盘操作图片按钮 -->
<div id="areaOption" style="display:none">
  <table border="0" cellpadding="0" cellspacing="0" id="ico3" >
    <tr>
      <td class="toolbarico">&nbsp;</td>
      <pms:AuthTag authName="house_areaAction.do?method=initAreaBaseEdit">
      <td class="toolbarico"><a href="#"  onClick="openAreaEdit();" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改楼盘资料"/></a></td>
     </pms:AuthTag>
    </tr>
  </table>
</div>

	<pms:tabPanel panelId="areaBase" hasTop="true" iframeId="areaInfo" defaultHeight="400px">

		<pms:tab tabId="projectInfo"
				 baseUrl="${ctx}/house_projectAction.do?method=initProjectList&areaId=${areaId}"
				 caption="期数资料"
				 rightDiv="projectOption"
				 beforeFunction="project.projectId = null;"
				 >
		</pms:tab>

		<pms:tab tabId="areaBaseInfo"
				 baseUrl="${ctx}/house_areaAction.do?method=initAreaInformation&areaId=${areaId}"
				 caption="楼盘资料"
				 rightDiv="areaOption"
				 beforeFunction="project.projectId = null;"
				 defaultTab="true"
				 >
		</pms:tab>
	</pms:tabPanel>


</body>
</html>
